package com.db.patterns.server;

import java.util.ArrayList;
import java.util.List;

import cm.db.patterns.commands.Command;

public class ClientListener implements CacheListener {

	List<ClientCache> clients = new ArrayList<>();
	@Override
	public void update(Command command) {
		for (ClientCache cache : clients)
			cache.update(command);
	}
	
	public void addClient(ClientCache cache) {
		clients.add(cache);
	}
	
	public void removeClient(ClientCache cache) {
		clients.remove(cache);
	}

	@Override
	public void stop() {
		clients.clear();
	}	
}
